const metaInfo = [
  {
    url: '/',
    title: 'ssr demo',
    keywords: 'vue ssr',
    description: 'vue srr demo',
  },
  {
    url: '/demo',
    title: 'ssr 2222',
    keywords: 'vue ssr 222',
    description: 'vue srr 222',
  },
];

function getMetaData(url) {
  // eslint-disable-next-line no-plusplus
  for (let i = 0; i < metaInfo.length; i++) {
    if (metaInfo[i].url === url) {
      return metaInfo[i];
    }
  }
  return metaInfo[0];
}

module.exports.getMetaData = getMetaData;

module.exports.convertMetaDataToHead = (path) => {
  const metaData = getMetaData(path);
  return {
    head: `
      <title>${metaData.title}</title>
      <meta name="keywords" content="${metaData.keywords}">
      <meta name="description" content="${metaData.description}">
    `, // 可以将分享meta信息传入head
  };
};
